package com.xr;

import com.xr.controller.HelloController;
import com.xr.pojo.Person;
import com.xr.pojo.Person2;
import com.xr.pojo.Person3;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ImportResource;
import org.springframework.test.context.junit4.SpringRunner;

@ImportResource(value = {"classpath:beans.xml"})
@RunWith(SpringRunner.class)
@SpringBootTest
@SpringBootApplication//对主启动类进行初始化并启动
public class SpringBoot0102Application {

    @Autowired//自动装配
    private Person person;

    @Autowired//自动装配
    private Person2 person2;

    @Autowired//自动装配
    private Person3 person3;

    @Autowired
    ApplicationContext ac;

    @Autowired//自动装配
    private Dog dog;

    public static void main(String[] args) {

        //string容器
        ApplicationContext context = SpringApplication.run(SpringBoot0102Application.class, args);
        HelloController bean = context.getBean(HelloController.class);
        System.out.println(bean);

    }

    @Test
    public void test() {
        //刚添加的
        System.out.println("haha");
        System.out.println(person);
        System.out.println(person2);
        System.out.println(dog);
        System.out.println(person3);
//
        boolean helloService = ac.containsBean("helloService");
        System.out.println(helloService);
    }


}
